package com.tgy.programmer_code_interview_guide._04_recursion_dynamicProgramming;

public class _02_台阶数 {

    public static int step(int n) {

        if (n == 1) {
            return 1;
        }

        if (n == 2) {

            return 2;
        }

        int first = 1, second = 2;
        int tmp;
        for (int i = 3; i <= n; i++) {

            tmp = second;
            second = second + first;
            first = tmp;
        }

        return second;
    }


    public static void main(String[] args) {

        int step = step(8);
        System.out.println(step);
    }
}
